package com.fg.cloud.manager.mapper.agency;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.fg.cloud.manager.entry.agency.AgencyImagesEntity;
import com.fg.cloud.manager.entry.agency.vo.AgencyInvoiceVo;
import com.fg.cloud.manager.entry.agency.vo.AgencyVo;
import com.fg.cloud.manager.mapper.BaseMapper;


/**
 * 经销商Mapper
 * @author around
 * @date 2017-6-20
 */
public interface AgencyMapper extends BaseMapper {
	
	AgencyVo selectByPrimaryKey(Long id);
	
	/**
	 * Description:经销商详情信息查询
	 * @param id 经销商ID
	 * @param facId 厂商ID，选填
	 * @return
	 * @author around
	 * @date 2017年9月8日上午11:26:05
	 */
	AgencyVo selectAgencyInfo(@Param("id")Long id, @Param("facId")Long facId);
	
	Long selectBycondition(@Param("id")Long id, @Param("facId")Long facId);
	
	AgencyInvoiceVo finds(Long id);
	
    int deleteByPrimaryKey(Long id);
    
    /**
      * Description:经销商图片查询
      * @param agencyId
      * @return
      * @author shaoqiping
      * @date 2017年8月15日上午11:41:13
    */
    List<AgencyImagesEntity> selectImgs(Long agencyId);
    
    List<String> selectImage(Long agencyId);
    
    /**
      * Description:经销商图片插入
      * @return
      * @author shaoqiping
      * @param imgArray 
      * @param agencyId 
      * @date 2017年8月15日上午10:36:54
    */
    int insertImgs(@Param("agencyId")Long agencyId, @Param("imgArray")String[] imgArray);
    
    /**
      * Description:经销商图片删除
      * @param agencyId
      * @return
      * @author shaoqiping
      * @date 2017年8月15日上午10:38:33
    */
    int deleteImgs(Long[] agencyId);
    /**
     * Description:查询经销商信息by Select控件
     * @param facId 厂商ID
     * @param filter 过滤内容
     * @return
     * @author around
     * @date 2017年8月3日上午9:24:54
     */
    List<com.fg.cloud.common.construction.Select> selectBySelect(
    		@Param("agency")AgencyVo agency, 
    		@Param("filter") String filter);
    
    /**
     * Description:
     * @param facId
     * @param filter
     * @return
     * @author around
     * @date 2017年10月11日下午3:36:42
     */
    List<com.fg.cloud.common.construction.Select> selectNewsBySelect(@Param("facId") Long facId, 
    		@Param("filter") String filter);
    
    
    /**
     * 查询厂商下属经销商列表数据
     * @param factoryId
     * @return List<AgencyVo>
     */
    @Select("select id, ageNumber, ageName from t_agency_info "
    		+ "where facId = #{facId} order by ageName asc")
    List<AgencyVo> selectByFactory(Long facId);
    
    @Select("select id, ageNumber as value, ageName as label "
    		+ "from t_agency_info where facId = #{facId} order by ageName asc")
    List<com.fg.cloud.common.construction.Select> findListByFacId(Long facId);
    
    long updateStatus(@Param ("userId")Long userId,@Param("facId") Long facId, 
    		@Param ("ids")Long[] ids, @Param ("status")Integer status);
    
    /**
     * Description:唯一性校验
     * @param id
     * @param facId
     * @param field
     * @param value
     * @return
     * @author around
     * @date 2017年9月24日下午4:26:30
     */
    long verifyUniquely(@Param("id")Long id, @Param("facId")Long facId, 
    		@Param("field")String field, @Param("value")Object value);
    
    
    int deletePic(@Param("ageId")Long ageId, @Param("picUrl")String picUrl);
    
    long batchDeleteImage(@Param("ageId")Long ageId, @Param("imgArray")List<String> picUrl);
    
    long batchInsertImage(@Param("ageId")Long ageId, 
    		@Param("imgArray")List<AgencyImagesEntity> imageList);
    
    int addImgs(AgencyImagesEntity images);
    

    
}